
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rotempco.Core.ORM.ADAL;
using System.Data.SqlClient;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.Core.ORM.Objects;
using Rotempco.Core.ORM.Objects.Enums;
using Rotempco.Core.ORM.Logic;
using Rotempco.Core.Logic;




namespace Rotempco.BaseClass.DAL
{
    public partial class SiteAttributeStoreData : ADAL<SiteAttributeStore, long>
    {
	    #region [ ADATA Implementation ]

        protected override string GetTableName()
        {
            return "SiteAttributeStore";
        }

        protected override Pair<string, string> GetIdentity()
        {
            return new Pair<string, string>("SiteAttributeStoreId", SymbolExtensions.GetPropertyName((SiteAttributeStore d) => d.SiteAttributeStoreId));
        }

        protected override List<ORMParameter> GetORMMapping()
        {
            List<ORMParameter> mapping = new List<ORMParameter>();
		
			mapping.Add(new ORMParameter("KeyName", SymbolExtensions.GetPropertyPair((SiteAttributeStore d) => d.KeyName)));
			mapping.Add(new ORMParameter("Value", SymbolExtensions.GetPropertyPair((SiteAttributeStore d) => d.Value)));

            return mapping;
        }

        #endregion

        #region [ GetBy ]

        public SiteAttributeStore GetSingle(bool getDeleted = false, long? siteAttributeStoreId = null, string keyName = null, string value = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(siteAttributeStoreId: siteAttributeStoreId, keyName: keyName, value: value);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, nullablePairList: nullablePairList).SingleOrDefault();
        }

        public List<SiteAttributeStore> GetList(bool getDeleted = false, long? getFirstEntries = null, long? getLastEntries = null, long? siteAttributeStoreId = null, string keyName = null, string value = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(siteAttributeStoreId: siteAttributeStoreId, keyName: keyName, value: value);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, getFirstEntries, getLastEntries, nullablePairList: nullablePairList);
        }

        #endregion

        #region [ Private ]

        private List<PropertyPair> GetByParameterList(long? siteAttributeStoreId = null, string keyName = null, string value = null)
        {
            List<PropertyPair> mapping = new List<PropertyPair>();

			mapping.Add(new PropertyPair(siteAttributeStoreId, SymbolExtensions.GetPropertyPair((SiteAttributeStore d) => d.SiteAttributeStoreId)));
			mapping.Add(new PropertyPair(keyName, SymbolExtensions.GetPropertyPair((SiteAttributeStore d) => d.KeyName)));
			mapping.Add(new PropertyPair(value, SymbolExtensions.GetPropertyPair((SiteAttributeStore d) => d.Value)));

            return mapping;
        }

        private List<NullablePair> GetNullablePairList()
        {
            List<NullablePair> nullablePairList = new List<NullablePair>();



            if (nullablePairList.Count <= 0)
                return null;

            return nullablePairList;
        }

        #endregion

	}
}

